//
//  HLStatuses.m
//  weibo-OC
//
//  Created by 黄力 on 15/12/21.
//  Copyright © 2015年 HLTest. All rights reserved.
//

#import "HLStatuses.h"

@implementation HLStatuses

+ (instancetype)statusesWithDictionary:(NSDictionary *)dic {
    //创建对象
    HLStatuses *statuses = [[HLStatuses alloc] init];
    //字典模型
    [statuses setValuesForKeysWithDictionary:dic];
    //返回
    return statuses;
}

- (void)setValue:(id)value forKey:(NSString *)key {
    //当key为"id"时,进行赋值
    if ([key isEqualToString:@"id"]) {
        _statusId = value;
        return;
    }
    //当key为"status"时,进行字典转模型
    if ([key isEqualToString:@"retweeted_status"]) {
        _retweeted_status = [HLStatuses statusesWithDictionary:value];
        return;
    }
    //当key为"user"时再进行一次字典转模型
    if ([key isEqualToString:@"user"]) {
        _user = [HLStatusesUser statusesUserWithDictionary:value];
        return;
    }
    [super setValue:value forKey:key];
}

//抛出为找到的key
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {}

//返回图片地址数组
- (NSArray *)imageUrlArr {
    //创建一个可变数组
    NSMutableArray *arrM = [NSMutableArray array];
    //遍历
    for (NSDictionary *urlDic in self.pic_urls) {
        NSString *urlStr = urlDic[@"thumbnail_pic"];
        //更换成高清图片
        urlStr = [urlStr stringByReplacingOccurrencesOfString:@"thumbnail" withString:@"large"];
        //创建url
        NSURL *url = [NSURL URLWithString:urlStr];
        //添加
        [arrM addObject:url];
    }
    return arrM.copy;
}


@end
